/*
 * @Author       : Thyssen Wen
 * @Date         : 2022-09-14 13:51:39
 * @LastEditors  : Thyssen Wen
 * @LastEditTime : 2022-09-14 13:57:17
 * @Description  : StringDisplay Class
 * @FilePath     : /cdesign-pattern/Template/StringDisplay.h
 */
#pragma once
#include "AbstractDisplay.h"
#include <string>
#include <iostream>

using namespace std;
class StringDisplay: public AbstractDisplay
{
private:
    string String;
    int width;
public:
    StringDisplay(string String);
    ~StringDisplay();

    void open();
    void print();
    void close();

    void printLine();
};

StringDisplay::StringDisplay(string String)
{
    this->String = String;
    this->width = String.length();
}

StringDisplay::~StringDisplay()
{
}

void StringDisplay::open()
{
    printLine();
}

void StringDisplay::print()
{
    cout << "|" << this->String << "|" << endl;
}

void StringDisplay::close()
{
    printLine();
}

void StringDisplay::printLine()
{
    cout << "+";
    for (int i = 0; i < this->width; i++)
    {
        cout << "-";
    }
    cout << "+" << endl;
}